package com.leetcode.structure;

import java.util.*;

/**
 *
 */
public class HashMapTest {

    public static void main(String[] args) {
        HashMap<Person, String> hashMap = new HashMap<>(16);
        Person man = new Person();
        man.setAge("18");
        man.setName("xiaolizi");
        Person boy = new Person();
        boy.setAge("18");
        boy.setName("xiaolizi");

        String put = hashMap.put(man, "男人");
        String put1 = hashMap.put(boy, "男孩");
        System.out.println(put);
        System.out.println(put1);
        System.out.println("------------------");
//        hashMap.forEach((person, s) -> {
//            System.out.println(s);
//        });
        Iterator<Map.Entry<Person, String>> iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Person, String> next = iterator.next();
        }
        System.out.println("------------------");
//        Person man1 = new Person();
//        man1.setAge("18");
//        man1.setName("xiaolizi");
//        System.out.println(hashMap.get(man1));
        List<String> list = Collections.synchronizedList(new LinkedList<>());
    }

    static int hash(Object key) {
        int h;
        return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
    }
}
